package wrs.hcs.tc;

import org.openqa.selenium.WebDriver;

import wrs.hcs.functions.*;

public class SpeciallyEndorsedPatient {

	public static WebDriver driver;
	public static String pin, mainWindow="", lName;
	
	static
	Webdriver d = new Webdriver();
	Login log = new Login();
	Logout out = new Logout();
	AdminConsole console = new AdminConsole();
	AdminConsole_Tracker act = new AdminConsole_Tracker();
	Miscellaneous m = new Miscellaneous();
	Hcs_Admission adm = new Hcs_Admission();
	Hcs_NewPatient newPatient = new Hcs_NewPatient();
	WebApp_Single s = new WebApp_Single();
	AdminConsole_Single acs = new AdminConsole_Single();
	
	public void webadmin() throws Exception{
		driver = d.startUp();
		log.admin(driver);
		String returned_string = console.create_single_inpatient_with_no_pin_in_admin(driver, "onlinediabetes", true);
		String[] arrString = returned_string.split(",");
		String lastName = arrString[0];
		String firstName = arrString[1];
		String admDate = arrString[2];
		
		String mainWindow = console.window_main_focus(driver);
		console.wellness_search_it(driver, lastName, firstName, admDate);
		
		console.check_patient_name_if_ends_at_sep(driver);
		console.get_status_and_click(driver, firstName, false);
		String text = m.set_dropdown_to_hcs("queue");
		console.select_dropdown_to_hcs(driver, text, "single");
		driver.switchTo().window(mainWindow);
		console.display_message_to_hcs(driver);
		console.wellness_search_it(driver, lastName, firstName, admDate);
		String pin = console.get_status_and_click(driver, "", false);
		act.goto_result_tracker(driver);
		act.tracker(driver, pin);
		out.admin(driver);
		
	}
	
	public void webapp() throws Exception{
		driver = d.startUp();
		log.hcs(driver, "admission");
		String getIt = newPatient.createPatient(driver, "adult");
		out.hcs(driver); 
		
		//Split string for PIN and LASTNAME
		String[] arrString = getIt.split(",");
		lName = arrString[0];
		pin = arrString[1];
		s.wellness(driver, lName, pin, false, "basic"); 
		
		log.admin(driver);
		acs.sep(driver, pin, "inpatient");
		out.admin(driver);
		
		log.hcs(driver, "nursing");
		Hcs_Nursing pack = new Hcs_Nursing();
		pack.validate(driver, pin); 											//validate package of patient
		pack.discharge(driver, pin); 											//fill up discharge instructions
		pack.pf(driver, pin); 													//assign pf and discharge
		out.hcs(driver);
		
		//driver = d.startUp();
		log.hcs(driver, "billing"); 											//das discharge
		Hcs_Billing bill = new Hcs_Billing();
		bill.das(driver, pin); 
		out.hcs(driver);
	
		log.hcs(driver, "nursing"); 											//print gatepass
		pack.gatepass(driver, pin);
		out.hcs(driver);
		driver.close();
		
	}
	
	
	
}
